import json

with open('src/前端/data.json', 'r') as f:
    data = json.load(f)

# 保留最近50条数据
with open('src/前端/data.json', 'w') as f:
    json.dump(data[-50:], f, indent=2)